package com.render.gui;

import org.lwjgl.input.Keyboard;

import base.common.IInput;
import base.render.gui.Gui;

public class GuiBirthday extends Gui implements IInput
{
	private boolean celebrateBirthday = true;
	private GuiStreak[] streaks;
	private String birthday = "";

	public GuiBirthday(GuiStreak[] par1GuiStreak)
	{
		this.streaks = par1GuiStreak;
	}

	@Override
	public void onUpdate() {}

	@Override
	public void onInputUpdate()
	{
		if (this.celebrateBirthday && Keyboard.next() && !Keyboard.isRepeatEvent())
		{
			if (Keyboard.isKeyDown(Keyboard.KEY_RETURN))
			{
				birthday = "";
				System.out.println("");
			}
			else
			{
				char i = Keyboard.getEventCharacter();
				if ((int) i >= (int) 'A' && (int) i <= 'z')
				{
					birthday += i;
					System.out.print(i);

					if (birthday.equalsIgnoreCase("S"))
					{
						this.setAllStreakColor(0x00FFF2);
					}
					else if (birthday.equalsIgnoreCase("SP"))
					{
						this.setAllStreakColor(0x15FF00);
					}
					else if (birthday.equalsIgnoreCase("SPE"))
					{
						this.setAllStreakColor(0x0D00FF);
					}
					else if (birthday.equalsIgnoreCase("SPEN"))
					{
						this.setAllStreakColor(0xFF00DD);
					}
					else if (birthday.equalsIgnoreCase("SPENC"))
					{
						this.setAllStreakColor(0x9900FF);
					}
					else if (birthday.equalsIgnoreCase("SPENCE"))
					{
						this.setAllStreakColor(0xFFFB00);
					}
					else if (birthday.equalsIgnoreCase("SPENCER"))
					{
						this.setAllStreakColor(0xFFFFFF);

						System.out.println();
						System.out.println("     HAPPY BIRTHDAY!!!\n" +
								"         SPENCER\n" +
								"          ,,,,,\n" +
								"         _|||||_ \n" +
								"        {~*~*~*~}\n" +
								"      __{*~*~*~*}__\n" +
								"     `-------------`\n" +
								"////////////////////////////\n" +
								"          11/26\n" +
								"////////////////////////////\n");

						this.celebrateBirthday = false;
					}
					else if (birthday.contains("S"))
					{
						birthday = "";
						System.out.println();
						this.setAllStreakColor(0xFF0000);
					}
					else
					{
						this.setAllStreakColor(rand.nextInt(0xFFFFFF));
					}
				}
			}

			return;
		}
	}

	@Override
	public void onRender() {}

	private void setAllStreakColor(int par1)
	{
		for(GuiStreak streak : streaks)
		{
			streak.setStreakColor(par1);
		}
	}
}
